/*
 * Copyright (c) 2018-2999 湖南洛云网络科技有限公司 All rights reserved.
 *
 * https://www.gz-yami.com/
 *
 */

package com.yami.shop.platform.controller;


import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yami.shop.bean.model.WebConfig;
import com.yami.shop.common.annotation.SysLog;
import com.yami.shop.common.util.PageParam;
import com.yami.shop.service.WebConfigService;
import lombok.AllArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * @author SJL
 * @date 2021-02-20 09:44:42
 */
@RestController
@AllArgsConstructor
@RequestMapping("/sys/webConfig")
public class WebConfigController {

    private final WebConfigService webConfigService;

    /**
     * 分页查询
     *
     * @param page      分页对象
     * @param webConfig
     * @return 分页数据
     */
    @GetMapping("/page")
    public ResponseEntity<IPage<WebConfig>> getWebConfigPage(PageParam<WebConfig> page, WebConfig webConfig) {
        return ResponseEntity.ok(webConfigService.getPageByConfigType(page,webConfig));
    }


    /**
     * 通过id查询
     *
     * @param id id
     * @return 单个数据
     */
    @GetMapping("/info/{id}")
    public ResponseEntity<WebConfig> getById(@PathVariable("id") Integer id) {
        return ResponseEntity.ok(webConfigService.getById(id));
    }


    /**
     * 获取当前激活的平台端网站配置
     *
     * @return
     */
    @GetMapping("/getActivity")
    public WebConfig getActivityWebConfig() {
        return webConfigService.getActivityWebConfig(1);
    }
}
